/**
 */
;
(function(){
'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.controller('WarningReAuditCtrl', ['$scope','$modal','$state', 
	                                  '$stateParams','WarningAddService','BaseURL','Modal',
	    function ($scope,$modal,$state,$stateParams,WarningAddService,baseUrl,Modal) {
		$scope.serv = WarningAddService;
		var warnNo=$stateParams.warnNo;
		$scope.complainModeList=[];
		var codeType=['COMPLAIN_TYPE'];
		function init(){
			WarningAddService.getHcpmsCodeList(codeType).success(function(response){
			        $scope.complainModeList = response.result;
		    });
		}
		init();
		WarningAddService.getHcpmsWarning({warnNo:warnNo})
		.success(function(res){
				$scope.warningFrom=res.warnInfo;
                $scope.warnScreenList=res.warnScreenList;
                $scope.warningMedical=res.warnMedicalList;
        		$scope.warningStaff=res.warnStaffList;
        		$scope.warningInsurance=res.warnInsuranceList;
        		setWarningInfoValue(res.warnInfo);
	     });
		
		function setWarningInfoValue(info){
			angular.forEach($scope.complainModeList,function(data,index){
				   if(data.codeNo===info.complain){
					   data.checked = true;
				   }
			   });
		}
		$scope.baseUrl='views/hcpms/warning/warnView/warningViewBase_view.html';
		$scope.screenUrl='views/hcpms/warning/warnView/warningViewScreen_view.html';
		$scope.processUrl='views/hcpms/warning/warnEdit/warningEditProcess_view.html';
		$scope.baseTabs=[{label:'医疗机构',id:0,url:'views/hcpms/warning/warnView/warningViewMedical_view.html'},
		             {label:'医护人员',id:1,url:'views/hcpms/warning/warnView/warningViewStaff_view.html'},
		             {label:'参保人员',id:2,url:'views/hcpms/warning/warnView/warningViewInsurance_view.html'}];
		$scope.selectedBaseTab = $scope.baseTabs[0];
		$scope.currentBaseTabIndex = 0;
		
		$scope.flowTabs=[{label:'网上筛查',id:0,url:'views/hcpms/warning/warnView/warningViewBase_view.html'},
			             {label:'自查结果',id:1,url:'views/hcpms/warning/warnView/warningViewStaff_view.html'},
			             {label:'结果评估',id:2,url:'views/hcpms/warning/warnView/warningViewInsurance_view.html'},
			             {label:'复审意见',id:2,url:'views/hcpms/warning/warnView/warningViewMedical_view.html'}];
		$scope.selectedFlowTab = $scope.flowTabs[0];
		$scope.currentFlowTabIndex = 0;
		
		$scope.tabBaseClick = function(tab) {
			$scope.selectedBaseTab = tab;
			$scope.currentBaseTabIndex=tab.id;
		}
		$scope.tabFlowClick = function(tab) {
			$scope.selectedFlowTab = tab;
			$scope.currentFlowTabIndex=tab.id;
		}
		$scope.process={};
		$scope.submitProcess = function (){
			if($scope.process.suggestion === '02'&&!$scope.process.explain){
				Modal.alert("不同意时,审核意见不能为空!");
				return;
			}
		   var param={warnNo:$scope.warningFrom.warnNo,
				      auditOpinion:$scope.process.suggestion,
				      auditDesc:$scope.process.explain};
		   Modal.alert("不同意,要同意请先给钱!");
		}
	   $scope.backWarning = function(){
        	$state.go("warning.warningList");
        }
	}]);
})();